﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for Servico
/// </summary>
public class Servico
{
    private String stConn = ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString;

    //private String idServico;
    //private String servico;
    //private double preco;
    //private DateTime tempo;

    public Servico()
    {
        this.servico = null;
        this.preco = "0.00";
        this.tempo = "";// DateTime.MinValue;
    }

    public Servico(string id)
    {        
        load(id);        
        //CarregaPermissoes(user);
    }

    public void limpar()
    {
        this.servico = null;
        this.preco = "0.00";
        this.tempo = "";// DateTime.MinValue;
        ultimoServico();
    }

    public String ultimoServico()
    {
        String sql = "select max(idServico) as idServico from servicos";
        String v_id;
        DataTable dtbdados = new DataTable();
        Execute a = new Execute();


        dtbdados = a.Pesquisar(sql);
        v_id = dtbdados.Rows[0]["idServico"].ToString();
        return v_id;      
    }

     //utilizada no cadastronovo
    private void load(String id)//usuario aqui
    {
        string sql = "select * from servicos where idServico =" + int.Parse(id);
        DataTable dtbdados = new DataTable();
        Execute a = new Execute();

        dtbdados = a.Pesquisar(sql);

        if (dtbdados.Rows.Count > 0)
        {           
            this.idServico = dtbdados.Rows[0]["idServico"].ToString();
            this.servico   = dtbdados.Rows[0]["servico"].ToString();
            this.preco     = dtbdados.Rows[0]["preco"].ToString();
            this.tempo     = dtbdados.Rows[0]["tempo"].ToString();            
        }
    }


    public String idServico
    {
        get;
        set;
    }
    public String servico
    {
        get;
        set;
    }
    public String preco
    {
        get;
        set;
    }
    public String tempo
    {
        get;
        set;
    }
}
